#pragma once

#include "SP.h"

//----------------------------------------------------------------------
// SPSprite
//----------------------------------------------------------------------
namespace SP
{
	class SPSprite : public SPD3DObject
	{
	public:
		SPSprite();
		~SPSprite();

		void Draw();
		void SetRect( const XMFLOAT4& vRect_TopBottomLeftRight );
		void SetColour( const XMFLOAT4& vColour );

	protected:
		struct VERTEX
		{
			XMFLOAT3 pos;
			XMFLOAT4 colour;
			XMFLOAT2 tex;
			VERTEX(){}
			VERTEX( const XMFLOAT3& p, 
				const XMFLOAT4& c, 
				const XMFLOAT2& t )
				: pos( p ), colour( c ), tex( t ){	}
		};

		ID3D11Buffer* m_pVB;	
		VERTEX m_vertices[6];
		ID3D11ShaderResourceView* m_pTex;

		friend class SPSpriteRenderer; 
	};

}
	
//----------------------------------------------------------------------
// SPFontSprite
//----------------------------------------------------------------------
namespace SP
{
	class SPFontSprite : public SPD3DObject
	{
	public:
		SPFontSprite( WCHAR* str );
		SPFontSprite( UINT maxLetter );
		~SPFontSprite();

		void Draw();
		void Create( UINT maxChar, WCHAR* str = NULL );

		struct FontAttribution
		{
			WCHAR* str;
			
		};

		void TextRebuild( WCHAR* str );
		inline void SetGlyphSize( const XMFLOAT2& vGlyphSize );
		inline void SetScreenRect( const XMFLOAT4& vSR, bool bCenter = false );
		inline void SetColour( const XMFLOAT4& vColour );
		
		void RebuildFrontSprite();
	protected:
		struct VERTEX
		{
			XMFLOAT3 pos;
			XMFLOAT2 tex;

			VERTEX(){}
			VERTEX( const XMFLOAT3& p, 
				const XMFLOAT2& t )
				: pos( p ), tex( t ){	}
		};

		UINT m_nNumChar;
		UINT m_nMaxLetter;
		UINT m_nDrawCount;
		WCHAR* m_pText;
		VERTEX* m_pVertices;
		ID3D11Buffer* m_pVB;

		XMFLOAT4 m_vColour;	
		bool m_bCenter;
		XMFLOAT2 m_vGlyphSize;
		XMFLOAT4 m_vRect;

		void BulidVertices();
		void SetZero();
		void Release();
		
		friend class SPFontSpriteRenderer;
	};
}



//----------------------------------------------------------------------
// SPHUDObject
//----------------------------------------------------------------------
namespace SP
{
	class SPHUDObject
	{
	public:
		SPHUDObject();
		virtual ~SPHUDObject();

		void OnMouseEvent( FLOAT x, FLOAT y, bool left, bool mid, bool right );
		
		virtual void Create() = 0;
		virtual void Init() = 0;
		virtual void Tick( FLOAT fElapsedTime ) = 0;
		virtual void Draw() = 0;

	protected:
		XMFLOAT4 m_vRect;
	};
}

//----------------------------------------------------------------------
// SPHUD
//----------------------------------------------------------------------
namespace SP
{
	class SPHUD
	{
	public:
		SPHUD();
		virtual ~SPHUD();

		void Tick( FLOAT fElapsdTime );
		void Draw();
	protected:
		std::list<SPHUDObject*> m_HUDObjectList;
	};



}